function P = prepareP2(m, n)
%PREPAREP Summary of this function goes here
%   Detailed explanation goes here
m_ = floor(m/2);
n_ = floor(n/2);

parityM = false;
parityN = false;
rows=0;
if mod(m,2) == 0
    parityM = true;
    m = m+1;
    rows=1;
end
if(mod(n,2) == 0)
    parityN = true;
    n=n+1;
end

P = zeros(m*n, floor(m/2)*floor(n/2));
qua = [1 3 1+2*m 3+2*m];
hal = [2 1+m 3+m 2+2*m];
one = 2+m;

for i=0:n_-1
    for j=0:m_-1
        P(qua + j*(2+m*n) + i*2*m + i*m*n*m_) = 0.25;
        P(hal + j*(2+m*n) + i*2*m + i*m*n*m_) = 0.5;
        P(one + j*(2+m*n) + i*2*m + i*m*n*m_) = 1;
    end    
end

% Handle special cases of even number of rows/columns
if parityM
    lst = [];
    for i=1:m-1
        lst = [lst i:m:m*n];
    end
    %P=P(sort([1:3:end 2:3:end],2),:); %wrong.. only for 3
    P=P(sort(lst,2),:);
end
if parityN
    P=P(1:end-m+rows, :);
end

end

